package work.chenbo.springboot.security.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class UserDetailsServiceImpl implements UserDetailsService {


    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
       String password = "123456";
       log.info("收到的账号为:{}",username);
       log.info("数据库查询到的密码为:{}",password);
       return new User(username,password, AuthorityUtils.commaSeparatedStringToAuthorityList("ROLE_USER"));
    }
}
